package cn.yyh.serviceOrder.controller;

import cn.yyh.commons.utils.R;
import cn.yyh.serviceOrder.domain.PetAcquisitionOrder;
import cn.yyh.serviceOrder.service.IPetAcquisitionOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/serviceOrder/petAcquisitionOrder")
public class PetAcquisitionOrderController {
    @Autowired
    private IPetAcquisitionOrderService petAcquisitionOrderService;

    @PostMapping
    public R save(@RequestBody PetAcquisitionOrder order) {
        try {
            petAcquisitionOrderService.save(order);
            return R.oK();
        } catch (Exception e) {
            e.printStackTrace();
            return R.error();
        }
    }

    @GetMapping("{id}")
    public R getById(@PathVariable Long id) {
        try {
            PetAcquisitionOrder byId = petAcquisitionOrderService.getById(id);
            return R.oK().data("acquisition",byId);
        } catch (Exception e) {
            e.printStackTrace();
            return R.error();
        }
    }

}
